package com.shuzijun.leetcode.editor.cn;
public class SearchA2dMatrix{
    public static void main(String[] args) {
         Solution solution = new SearchA2dMatrix().new Solution();
        
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length;
        int n = matrix[0].length;
        int low = 0,high = m*n-1;
        int mid,midValue;
        while (low <= high){
            mid = (low+high)/2;
            midValue = matrix[mid/n][mid%n];
            if (target == midValue){
                return true;
            } else if (target < midValue) {
                high = mid-1;
            }else {
                low = mid+1;
            }
        }
        return false;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}